
import com.mysql.jdbc.Connection;
import java.sql.DriverManager;


class DBManager  
{  
    private  static Connection connection = null;  
    private static DBManager dbmanager; 
    
      
   private DBManager()throws Exception  
   {  
        if (connection == null)  
        {  
         
            try  
            {  
              
                 Class.forName("com.mysql.jdbc.Driver");
                 connection = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "password");
                
            }  
            catch (Exception e)  
            {  
                e.printStackTrace();  
                connection = null;  
                throw e;  
            }  
        }         
   }  
  
    public static Connection openDBConnection() throws Exception  
    {  
        dbmanager = new DBManager();  
        return connection;  
    }  
}  
  